const app = getApp()
//获得全局js变量
var util = require('../../../utils/util.js');
Page({
    data: {
        teamMembers: [],
        totalMembers: 0,
        directMembers: 0,
        indirectMembers: 0,
        myPerformance: 0,     // 我的业绩
        teamPerformance: 0    // 团队业绩
    },
    
    onLoad: function() {
        this.getTeamInfo();
    },
    
    // 获取团队信息
    getTeamInfo: function() {
        // 模拟从服务器获取数据
		var that = this;
		util.httpRrquest(app.data.rooturl + 'user/getTeam', 'GET')
        .then(function (response) {
            console.log(response.data.data);
			const res = response.data.data;
            that.setData({
				teamMembers: res.data,
				totalMembers: res.team.teamPersonNum,
				directMembers: res.team.firstLineNum,
				indirectMembers: res.team.teamPersonNum-res.team.firstLineNum,
				myPerformance: res.team.myNum,
				teamPerformance: res.team.teamMoneyNum
			});
        }, function (error) {
            console.log(error);
        });
    }
})